Repository navigation
feat(start): quick-start Vietnamese campaign templates (Refs #338) - #343
Conversation
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
PO acceptance: merge at 13fc78b |
Refs #338
Summary
apps/web/src/lib/campaign-templates.ts(+campaign-templates.test.ts) with 5 curated Vietnamese templates (blank,medical_emergency,education_community,relief_environment,creative_product) and strict allowlist lookupgetCampaignTemplate(id).StartCampaignForm(apps/web/src/app/start/StartCampaignForm.tsx+StartCampaignForm.test.ts) wired into/start(apps/web/src/app/start/page.tsx+page.test.ts):radiogroupusingDESIGN.mdsemantic tokens, spacing, and focus rings (noscript:hiddenfor zero-JS safety).type, formattedgoal_amount, title placeholder/hint, and hiddentemplate_idwhile preserving user-entered titles, manual overrides on re-click, pre-hydration edits, and zero-JS baseline submission.createCampaign(apps/web/src/app/start/actions.ts+actions.test.ts):null/"blank"behavior 100% identical to baseline with zero extra queries.categoriesFor(categories, type)so manual type overrides never mismatch DB constraints), insertscategory_id,summary, and Markdownstory, and sequentially inserts 3 starter FAQs viaupsert_campaign_faqbest-effort without blocking draft creation or redirect.Verification
pnpm format:check— PASSpnpm --filter @give/web typecheck— PASSpnpm --filter @give/web lint— PASSpnpm --filter @give/web exec vitest run --maxWorkers=2 --fileParallelism=false— PASS (218 files, 2993 tests)pnpm --filter @give/web build— PASS📌 TL;DR
Introduces a "Quick Start" template selection feature to the campaign creation form, allowing users to pre-fill campaign type, goal amount, category, summary, story, and starter FAQs from five curated Vietnamese templates. The implementation ensures robust client-side state management (preserving user edits and supporting keyboard navigation) and server-side fault tolerance (non-blocking category/FAQ lookups) to streamline the onboarding experience.
🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/lib/campaign-templates.tsCampaignTemplateinterface and exports the 5 curated templates (blank, medical, education, relief, creative). Includes a safe lookup functiongetCampaignTemplateand a VND goal formatter.apps/web/src/lib/campaign-templates.test.tsgetCampaignTemplatelookup against prototype pollution and invalid inputs.apps/web/src/app/start/StartCampaignForm.tsxrole="radiogroup"template picker with roving tabindex keyboard navigation. Implements logic to pre-fill form fields (type, goal, title placeholder) while preserving user-entered values (title, custom goal) and handling hydration.apps/web/src/app/start/StartCampaignForm.test.tsapps/web/src/app/start/actions.tscreateCampaignserver action to accepttemplate_id. If a non-blank template is selected, it attempts to resolve thecategory_idand insert starter FAQs viarpc. These operations are wrapped intry/catchblocks to ensure that template enrichment failures never block the core campaign draft creation.apps/web/src/app/start/actions.test.tsapps/web/src/app/start/page.tsxStartCampaignFormcomponent, removing the inline form markup. Updates the page description to mention the new template options.apps/web/src/app/start/page.test.ts📊 Architectural Flow
sequenceDiagram participant User participant Form as StartCampaignForm (Client) participant Action as createCampaign (Server) participant DB as Supabase DB User->>Form: Selects Template (e.g., "medical_emergency") Form->>Form: Updates UI State (type, goal, placeholders) Note right of Form: Preserves user-entered Title/Goal<br/>if not matching template defaults User->>Form: Submits Form Form->>Action: POST FormData (includes template_id) Action->>Action: Validate & Parse Form Action->>Action: Resolve Template (getCampaignTemplate) alt Template is "blank" or invalid Action->>DB: Insert Campaign (Base Fields) else Template is active Action->>DB: List Categories DB-->>Action: Categories Action->>Action: Match Category Slug (non-blocking) Action->>DB: Insert Campaign (Base + Category + Summary + Story) DB-->>Action: Campaign ID loop For each Starter FAQ Action->>DB: RPC upsert_campaign_faq Note right of DB: Errors are caught & logged<br/>but do not fail the request end end Action->>Action: Revalidate & Redirect Action-->>User: Redirect to /me/campaigns/{id}